const COUNT = 100;
let container = document.body
let w = container.clientWidth;

const randomCode = () => {
    let randomCharCode = Math.floor(Math.random() * (127 - 32) + 32);
    return String.fromCharCode(randomCharCode);
}

const createCodeRain = () => {
    let code = document.createElement('div')
    code.className = 'code';
    code.style.left = `${Math.random() * w}px`;

    let str = '';
    for (let i = 0; i < 20; i++){
        str += randomCode();
    }
    code.innerText = str;
    code.style.transform = `translateZ(${(Math.random() - 0.5) * 1000}px) translateY(-120%)`;
    code.style.animationDelay = `${Math.random() * 8}s`;
    code.style.animationDuration = `${2 + Math.random() * 3}s`;
    container.appendChild(code);
}

let codes = new Array(COUNT).fill(0);
codes.forEach(() => {
    createCodeRain();
})